package com.mmren.edu.dtx.mapper;

import com.mmren.edu.dtx.domain.Stock;
import com.mmren.edu.dtx.vo.OrderVO;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import org.springframework.stereotype.Component;

/**
 * 欢迎来到牧码人教育，做Java我们是专业的
 *
 * @创建人： 牧码人教育-Gerry
 * @创建时间： 2020-4-20
 * @功能描述：
 */
@Mapper
@Component
public interface StockMapper {
    @Update("update t_stock set amount = amount - #{vo.amount} " +
            "where product_id = #{vo.productId}")
    int updateStock(@Param("vo")OrderVO vo);

    @Select("select amount from t_stock where product_id = #{productId}")
    Stock getStockByProductId(@Param("productId") Long productId);
}
